package com.alan.controller;

import com.alan.domain.ResponseResult;
import com.alan.domain.entity.Article;
import com.alan.service.ArticleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Resource
    private ArticleService articleService;

    @GetMapping("/hotArticleList")
    public ResponseResult hotArticle(){
        ResponseResult result = articleService.hotArticleList();
        return result;
    }

    /**
     * 更新浏览量
     */
    @PutMapping("/updateViewCount/{id}")
    public ResponseResult updateViewCount(@PathVariable("id")Long id){
        return articleService.updateViewCount(id);
    }


    /**
     * 展示文章列表
     */
    @GetMapping("/articleList")
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId){
        return articleService.articleList(pageNum,pageSize,categoryId);
    }

    /**
     * 查看文章详情
     */
    @GetMapping("/{id}")
    public ResponseResult getArticleDetail(@PathVariable("id") Integer id){
       return articleService.getArticleDetail(id);
    }
}
